home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 759 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: claus@faerber.muc.de (Claus A. Faerber)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: String value of enum
  5. Date: 18 Mar 1996 09:47:51 PST
  6. Organization: -
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <6525BH4ocDB@faerber.muc.de>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: Sun, 17 Mar 1996 01:00:00 +0100
  11. In-Reply-To: <4i5sf3$89c@hermes.is.co.za>
  12. X-Mailer: CrossPoint v3.1 R/B17071
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMU2h1Ey4NqrwXLNJAQGhCQIAzUNzr4dJh/+oxgy4YDDq637+NJIS2xjO
  15.     vhVtsWw5LOVAv6pp3vCvUGWG+9bOdsuZzZkWET0ytwiAxu2k3H7Wmw==
  16.     =QjjM
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. W. Dicks <wd@isis.co.za> (13 Mar 96):
  20.  
  21. > The system that I'm working often needs to know the string
  22. > value of an enum. e.g. enum week{MON=1, ..., SUN} it; it =
  23. > TUE;
  24. > Then when this enum is passed as a parameter the function
  25. > should return the string based on the enum. For instance,
  26. > weekImage(it) will return "TUE". Is it not possible that such
  27. > a functionality can be built into enums?
  28.  
  29. It is possible, but I would not appreciate it.
  30.   If this were possible, it would make the program's output  
  31. depend on internal variable/type names, which is generally  
  32. not a good idea. Especially when you want to translate your  
  33. program into other languages, it is easier to change this  
  34. enum-to-string function (or even a seperate string table)  
  35. instead of every line of code where this enum is used.
  36.  
  37. Claus
  38.  
  39. -------------------------------------------------------------------------
  40. Claus Andre Faerber - claus@faerber.muc.de - http://www.muc.de/~cfaerber/
  41. -------------------------------------------------------------------------
  42. ---
  43. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  44.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  45.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  46.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  47.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  48. ]
  49.